package guoanmaker.provider.business.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.provider.business.model.ProvideArea;
import guoanmaker.provider.business.model.ProvideCity;
import guoanmaker.provider.business.model.ProviderProvince;
import guoanmaker.provider.business.service.ProvideProCiAreServiceIntegerface;
import guoanmaker.provider.helper.common.AjaxJson;
import guoanmaker.provider.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;
@RestController
public class ProvideProCiAreController {
	@Autowired
	private  AjaxJson ajaxJson;
	@Autowired
	private ProvideProCiAreServiceIntegerface provideProCiAreServiceIntegerface;
	
	@ApiOperation(value="省列表", notes="查询")
	@RequestMapping(value = "/selProvinceList", method = RequestMethod.POST)
    public  AjaxJson selProvinceList() {
		List<ProviderProvince>   pros = provideProCiAreServiceIntegerface.selectprovice();
		if(pros.size()>0){
	  ajaxJson.setSuccess(true).setStatus(200).setData(pros);
	  }else{
		  ajaxJson.setSuccess(false).setStatus(250).setMsg("请联系管理员添加数据");
	  }
        return ajaxJson;

    }
	
	@ApiOperation(value="查询开通服务的省列表", notes="查询")
	@RequestMapping(value = "/selectOprtorProvice", method = RequestMethod.POST)
    public  AjaxJson selectOprtorProvice() {
		List<ProviderProvince>   pros = provideProCiAreServiceIntegerface.selectOprtorProvice();
		if(pros.size()>0){
			ajaxJson.setSuccess(true).setStatus(200).setData(pros);
		}else{
			ajaxJson.setSuccess(false).setStatus(250).setMsg("请联系管理员添加数据");
		}
        return ajaxJson;

    }
	
	
	@ApiOperation(value="市列表", notes="查询")
	@RequestMapping(value = "/selcityList", method = RequestMethod.POST)
    public  AjaxJson selcityList(String procode) {
		List<ProvideCity>   citys = provideProCiAreServiceIntegerface.selectcity(procode);
		if(citys.size()>0){
			  ajaxJson.setSuccess(true).setStatus(200).setData(citys);
			  }else{
				  ajaxJson.setSuccess(false).setStatus(250).setMsg("请联系管理员添加数据");
			  }
        return ajaxJson;

    }
	@ApiOperation(value="县列表", notes="查询")
	@RequestMapping(value = "/selAreaList", method = RequestMethod.POST)
    public  AjaxJson selAreaList(String citycode) {
		List<ProvideArea>   areas = provideProCiAreServiceIntegerface.selectarea(citycode);
		if(areas.size()>0){
			  ajaxJson.setSuccess(true).setStatus(200).setData(areas);
			  }else{
				  ajaxJson.setSuccess(false).setStatus(250).setMsg("请联系管理员添加数据");
			  }
        return ajaxJson;

    }
	
	
	@ApiOperation(value="市列表", notes="通过省级id查询地级市列表")
	@RequestMapping(value = "/selcityList2", method = RequestMethod.POST)
    public  AjaxJson selcityList2(String id) {
		ProviderProvince province=provideProCiAreServiceIntegerface.selectByID(id);
		String procode=province.getCode();
		List<ProvideCity>   citys = provideProCiAreServiceIntegerface.selectcity(procode);
		if(citys.size()>0){
			  ajaxJson.setSuccess(true).setStatus(200).setData(citys);
			  }else{
				  ajaxJson.setSuccess(false).setStatus(250).setMsg("请联系管理员添加数据");
			  }
        return ajaxJson;
    }
	
	@ApiOperation(value="县列表", notes="通过市级id查询县区列表")
	@RequestMapping(value = "/selAreaList2", method = RequestMethod.POST)
    public  AjaxJson selAreaList2(String id) {
		ProvideCity city=provideProCiAreServiceIntegerface.selectByCityID(id);
		String citycode=city.getCode();
		List<ProvideArea>   areas = provideProCiAreServiceIntegerface.selectarea(citycode);
		if(areas.size()>0){
			  ajaxJson.setSuccess(true).setStatus(200).setData(areas);
			  }else{
				  ajaxJson.setSuccess(false).setStatus(250).setMsg("请联系管理员添加数据");
			  }
        return ajaxJson;

    }
	
	@ApiOperation(value="市列表", notes="通过省级id查询开通服务地级市列表")
	@RequestMapping(value = "/selcityList3", method = RequestMethod.POST)
    public  AjaxJson selcityList3(String id) {
		ProviderProvince province=provideProCiAreServiceIntegerface.selectByID(id);
		String procode=province.getCode();
		List<ProvideCity>   citys = provideProCiAreServiceIntegerface.selectByProviceId(procode);
		if(citys!=null&&citys.size()>0){
			  ajaxJson.setSuccess(true).setStatus(200).setData(citys);
		}else{
			  ajaxJson.setSuccess(false).setStatus(250).setMsg("请联系管理员添加数据");
		}
        return ajaxJson;
    }
}
